﻿@model List<EasyToHelp.Entity.TableManageField>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>表单字段管理</title>
    <link href="/layui/css/layui.css" rel="stylesheet" />
    <script src="/layui/layui.js"></script>
    <script src="/lib/jquery/dist/jquery.min.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <blockquote class="layui-elem-quote layui-text">
        <div class="layui-row">
            <div class="layui-btn-group">
                <button onclick="Add()" class="layui-btn">
                    <i class="layui-icon">&#xe608;</i> 添加
                </button>
                <button onclick="synTableManageField('@ViewBag.TableName')" class="layui-btn">
                    <i class="layui-icon">&#xe608;</i> 同步
                </button>
            </div>
        </div>
    </blockquote>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>表单维护</legend>
    </fieldset>
    <table class="layui-table">
        <thead>
            <tr>
                <th>中文标题</th>
                <th>英文字段</th>
                <th>提示信息</th>
                <th>字段类型</th>
                <th>是否主键</th>
                <th>是否外键</th>
                <th>是否可见</th>
                <th>是否标题</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            @if (Model != null)
            {
                foreach (var item in Model)
                {
                    <tr>
                        <td>@item.ChineseName</td>
                        <td>@item.EnglishName</td>
                        <td>@item.Msg</td>
                        <td>@item.FieldType</td>
                        <td>@(item.IsPkName == true ? "是" : "否")</td>
                        <td>@(item.IsFkName == true ? "是" : "否")</td>
                        <td>@(item.IsSearchPkName == true ? "是" : "否")</td>
                        <td>@(item.IsTitle == true ? "是" : "否")</td>
                        <td>
                            <button onclick="Add()" class="layui-btn layui-btn-normal layui-btn-sm">新增</button>
                            <button onclick="UpdateField('Id' ,@item.Id)" class="layui-btn layui-btn-warm layui-btn-sm"><i class="layui-icon"></i>编辑</button>
                            <button onclick="del('Id', @item.Id)" class="layui-btn layui-btn-danger layui-btn-sm">删除</button>
                        </td>
                    </tr>
                }
            }
        </tbody>
    </table>
</body>
</html>
<script>
    //同步数据
    function synTableManageField(TableName) {
        $.post("/FormManage/synTableManageField", { TableName: TableName },
            function (data) {
                layui.use('layer', function () {
                    var layer = layui.layer;
                    if (data.code == 100) {
                        layer.alert(data.msg, { icon: 6 }, function () {
                            window.location.reload();
                        }
                        );
                    }
                    else {
                        layer.alert(data.msg, { icon: 5 });
                    }
                });
            }, "json");
    }
    function UpdateField(fkname, fkvalue) {
        layui.use('layer', function () {
            var layer = layui.layer;
            layer.open({
                type: 2,
                title: "表单配置",
                shadeClose: true,
                shade: 0.8,
                maxmin: true, //开启最大化最小化按钮
                area: ['600px', '500px'],
                content: '/FormManage/FormView?TableName=TableManageField&FkName=' + fkname + '&FkValue=' + fkvalue + ''
            });
        });
    }
</script>